'''
Created on 21/10/2012

@author: Chris

This module includes class and functions used for constructing draftmanger graphic user 
interface
'''

from Tkinter import Menu

from events import *

#=======================================================================================        
def init_menu(controller, master):
#=======================================================================================
    """ 
    menu construction
    controller is DMApp instance 
    """
    menubar = Menu(master)
    repomenu = Menu(menubar,tearoff=0)
    repomenu.add_command(label="Open",   command=lambda c=controller: open_repository(controller))
    repomenu.add_command(label="Add",    command=lambda c=controller: add_repository(controller))
    repomenu.add_command(label="Remove", command=lambda c=controller: remove_repo_node(controller))
#    repomenu.add_separator()
#    repomenu.add_command(label="Import", command=import_repository)
#    repomenu.add_command(label="Export", command=export_repository)
    repomenu.add_separator()
    repomenu.add_command(label="Exit",      command= master.quit)
    menubar.add_cascade(label="Repository", menu=repomenu)
        
        
    filemenu = Menu(menubar,tearoff=0)
    filemenu.add_command(label="Track file",     command=lambda c=controller: track_file(controller))
    filemenu.add_command(label="Untrack file",   command=lambda c=controller: untrack_file(controller))
    filemenu.add_command(label="Rename file",    command=lambda c=controller: rename_file(controller))
    filemenu.add_separator()
    filemenu.add_command(label="Checkout version",   command=lambda c=controller: checkout_file_version(controller))
    filemenu.add_command(label="Compare  version",   command=lambda c=controller: compare_version(controller))
    filemenu.add_command(label="View version",       command=lambda c=controller: view_file_version(controller))
    filemenu.add_separator()
    filemenu.add_command(label="Search in comment",  command=lambda c=controller: search_file(controller))
    menubar.add_cascade(label="File", menu=filemenu)
        
        
    confmenu = Menu(menubar,tearoff=0)
    confmenu.add_command(label="Auto-Save",    command=lambda c=controller: cnfg_atuosave(controller))
    confmenu.add_command(label="Compare Tool", command=lambda c=controller: cnfg_comparison_tool(controller))
    menubar.add_cascade(label="Config", menu=confmenu)
        
        
    helpmenu = Menu(menubar, tearoff=0)
    helpmenu.add_command(label="About",command=lambda c=controller: about(controller))
#    helpmenu.add_command(label="Help",  command=help_doc)
    menubar.add_cascade(label="Help",   menu=helpmenu)
    #statusBar = tk.Label(root, text="", bd=1, relief=SUNKEN, anchor=W)
    #statusBar.pack(side=BOTTOM, fill=X)
    master.config(menu=menubar)

